****Costa Rica dofile

***creates dependent variable nbdv

recode nbexpa 888888/999999=.
recode nbexpb 888888/999999=.
recode nbexpc 888888/999999=.
recode nbexpd 888888/999999=.

generate nbdv=.
replace nbdv=nbexpa if nbexpa <=10
replace nbdv=nbexpb if nbexpb <=10
replace nbdv=nbexpc if nbexpc <=10
replace nbdv=nbexpd if nbexpd <=10

****creates indicator variables for the cells

generate nlost=0
generate ngain=0
generate nneut=0
replace nlost=1 if nbexpa <=10
replace ngain=1 if nbexpb <=10
replace nneut=1 if nbexpc <=10

****creates the negativity variable (negbiasfin)

recode nb1 888888/999999=.
recode nb4 888888/999999=.
recode nb6 888888/999999=.
recode nb7 888888/999999=.

egen negbias=rmean(nb1 nb4 nb6 nb7)
gen negbiasfin= (10-negbias)


****recodes aditional control variables (robutness)

recode l1 888888/999999=.
recode etid 888888/999999=.
recode ed 888888/999999=.

****Regression models

reg nbdv i.ngain i.nneut i.nlost

reg nbdv c.negbiasfin##i.ngain c.negbiasfin##i.nneut c.negbiasfin##i.nlost

reg nbdv i.ngain i.nneut c.negbiasfin##i.nlost

reg nbdv i.ngain i.nneut c.negbiasfin##i.nlost i.q1 q2 l1 ed i.etid 
